﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Bll;
using Moned;

namespace Supermarket_management_system
{
    public partial class jeizhang : Form
    {
        public jeizhang()
        {
            InitializeComponent();
        }

        private void jeizhang_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F2)
            {
                getbian.Focus();
            }
            if(e.KeyCode==Keys.Enter)
            {
                souse_Click(null,null);
   
            }
            if (e.KeyCode == Keys.F5)
            {
                f5jei_Click(null,null);
            }

        }
        

        private void souse_Click(object sender, EventArgs e)
        {
            chaxun CX = new chaxun();
            CX.sql(getbian.Text);
            List<Foodsinfo> list = new List<Foodsinfo>();
            BuyList BL = new BuyList();
            List<BuyList> buylist = new List<BuyList>();
            list.Add(CX.sql(getbian.Text));
            if (getbian.Text != "")
            {
                if (list.Count == 0)
                {
                    MessageBox.Show("请输入正确的编号");
                }
                if (list.Count == 1)
                {
                    BL.GoodsName = list[0].GoodsName;
                    BL.SalePrice = list[0].SalePrice;
                    BL.shuliang = 1;
                    buylist.Add(BL);
                    dataGridView1.DataSource = buylist;
                }
                else
                {
                    goodtable GT = new goodtable();
                    GT.zailist = list;
                    GT.ShowDialog();
                    BL.GoodsName = list[0].GoodsName;
                    BL.SalePrice = list[0].SalePrice;
                    BL.shuliang = 1;
                    buylist.Add(BL);
                }
            }
            getbian.Text = "";
            
        }

        private void f5jei_Click(object sender, EventArgs e)
        {
            MessageBox.Show("结算");
        }

        private void jeizhang_Load(object sender, EventArgs e)
        {
            dataGridView1.AutoGenerateColumns = false;
        }
    }
}
